using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class so_JobCostMap : EntityTypeConfiguration<so_JobCost>
    {
        public so_JobCostMap()
        {
            // Primary Key
            this.HasKey(t => new { t.Job__, t.job, t.Account__, t.Cost_center, t.DATE, t.currency, t.project, t.cost_type, t.sumfields, t.dimfields });

            // Properties
            this.Property(t => t.Job__)
                .IsRequired()
                .HasMaxLength(6);

            this.Property(t => t.job)
                .IsRequired()
                .HasMaxLength(25);

            this.Property(t => t.Account__)
                .IsRequired()
                .HasMaxLength(40);

            this.Property(t => t.Cost_center)
                .IsRequired()
                .HasMaxLength(9);

            this.Property(t => t.BATCH)
                .HasMaxLength(8);

            this.Property(t => t.description)
                .HasMaxLength(130);

            this.Property(t => t.currency)
                .IsRequired()
                .HasMaxLength(5);

            this.Property(t => t.project)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.cost_type)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.sumfields)
                .IsRequired()
                .HasMaxLength(51);

            this.Property(t => t.dimfields)
                .IsRequired()
                .HasMaxLength(49);

            // Table & Column Mappings
            this.ToTable("so_JobCost");
            this.Property(t => t.job_ID).HasColumnName("job_ID");
            this.Property(t => t.Job__).HasColumnName("Job_#");
            this.Property(t => t.job).HasColumnName("job");
            this.Property(t => t.Account__).HasColumnName("Account_#");
            this.Property(t => t.Cost_center).HasColumnName("Cost_center");
            this.Property(t => t.BATCH).HasColumnName("BATCH");
            this.Property(t => t.DATE).HasColumnName("DATE");
            this.Property(t => t.description).HasColumnName("description");
            this.Property(t => t.currency).HasColumnName("currency");
            this.Property(t => t.Debit_account).HasColumnName("Debit_account");
            this.Property(t => t.Credit_account).HasColumnName("Credit_account");
            this.Property(t => t.Debit_base2).HasColumnName("Debit_base2");
            this.Property(t => t.Credit_base2).HasColumnName("Credit_base2");
            this.Property(t => t.debit_base1).HasColumnName("debit_base1");
            this.Property(t => t.credit_base1).HasColumnName("credit_base1");
            this.Property(t => t.project).HasColumnName("project");
            this.Property(t => t.cost_type).HasColumnName("cost_type");
            this.Property(t => t.sumfields).HasColumnName("sumfields");
            this.Property(t => t.dimfields).HasColumnName("dimfields");
        }
    }
}
